
<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<title>Hello MUI</title>
		<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">

		<!--标准mui.css-->
		<link rel="stylesheet" href="../css/mui.min.css">
	</head>
	<body>
		<header class="mui-bar mui-bar-nav">
			<h1 class="mui-title">追书神器(实全版)</h1>
		</header>
		<div class="mui-content">
			<div class="mui-indexed-list-search mui-input-row mui-search">
				<input type="search" class="mui-input-clear mui-indexed-list-search-input" placeholder="搜索图书">
			</div>
			<div id="scroll" class="mui-scroll-wrapper" style="margin-top: 80px;">
				<div class="mui-scroll">
					<!--<div class="mui-card">s</div>-->
					<div class="mui-card" style="margin-bottom: 35px;">
						<ul class="mui-table-view mui-table-view-chevron">
							<li class="mui-table-view-cell mui-media" v-for="item in books">
								<a class="mui-navigate-right" v-on:click="openWindow(item)">
									<img class="mui-media-object mui-pull-left" v-bind:src="item.cover">
									<div class="mui-media-body">
										<span v-html="item.title">CBD</span>
										<p class='mui-ellipsis' v-html="item.shortIntro">烤炉模式的城，到黄昏，如同打翻的调色盘一般.</p>
									</div>
								</a>
							</li>
						</ul>
					</div>
				</div>
			</div>
		</div>
		<script src="../js/mui.min.js"></script>
		<script src="../js/vue.min.js"></script>
		<script src="../js/categoryinfo.js"></script> 
		<script>
			mui.init();
			var vm = new Vue({
				el: '.mui-content',
				data: {
					gender:"male",
					major:"武侠",
					mins:[],
					type:"hot",
					minor:"",
					start:0,
					limit:20,
					total:0,
					books:[],
				}
			});
			mui.plusReady(function(){
				mui('#scroll').scroll({
					indicators: true //是否显示滚动条
				});
				loadData('hot');
			});
			
			function loadData(type){
				console.log("type="+type);
				plus.nativeUI.showWaiting("正在加载数据，请稍等...");
				/*https://api.zhuishushenqi.com/book/by-categories?gender=male&type=hot&major=%E5%A5%87%E5%B9%BB&minor=&start=0&limit=20*/
				var ajaxUrl = "https://api.zhuishushenqi.com/book/by-categories?type="+type+"&major="+vm.major+"&minor=&start="+vm.start+"&limit="+vm.limit;
				console.log(ajaxUrl);
				mui.getJSON(ajaxUrl, {}, function(rsp) {
					plus.nativeUI.closeWaiting();
					console.log(JSON.stringify(rsp));
					if(rsp.ok && rsp.ok == false){
						plus.nativeUI.alert(rsp.msg);
						return;
					}
					if(rsp.ok && rsp.ok == true){
						//vm.keyValue = rsp._id;
						vm.total = rsp.total;
						var books = rsp.books;
						books.forEach(function(item){
							//console.log(item.cover);
							item.cover ="http://statics.zhuishushenqi.com"+ item.cover;
						});
						vm.books = books;
					}
				});
			}
			
			function openWindow(item){
				console.log(JSON.stringify(item));
				mui.openWindow({id: 'bookinfo.html',url: 'bookinfo.html'
					,show: {aniShow: 'pop-in'}
					,extras: {    //extras里面的就是参数了
	                	keyValue: item._id,
	                	title:item.title,
	                	monthRank:item.monthRank,
	                	totalRank:item.totalRank,
	           		}
					,waiting: {
						autoShow: true, //自动显示等待框，默认为true
	           		}
  				});
			}
		</script>

	</body>

</html>